package com.example.licencecreate.common;

import java.io.Serializable;

public class ResultMessage implements Serializable {
    private Integer code;
    private String msg;
    private Object data;
    private static final int SUCCESS_CODE = 200;
    private static final int FAILURE_CODE = 500;
    public static final String SUCCESS_MSG = "success";
    public static final String FAILURE_MSG = "fail";

    public static ResultMessage newSuccessResult() {
        ResultMessage resultMessage = new ResultMessage();
        resultMessage.setCode(SUCCESS_CODE);
        resultMessage.setMsg(SUCCESS_MSG);
        return resultMessage;
    }

    public static ResultMessage newSuccessResult(String data) {
        ResultMessage resultMessage = new ResultMessage();
        resultMessage.setCode(SUCCESS_CODE);
        resultMessage.setMsg(SUCCESS_MSG);
        resultMessage.setData(data);
        return resultMessage;
    }

    public static ResultMessage newFailureResult() {
        ResultMessage resultMessage = new ResultMessage();
        resultMessage.setCode(FAILURE_CODE);
        resultMessage.setMsg(FAILURE_MSG);
        return resultMessage;
    }

    public static ResultMessage newFailureResult(String msg) {
        ResultMessage resultMessage = new ResultMessage();
        resultMessage.setCode(FAILURE_CODE);
        resultMessage.setMsg(msg);
        return resultMessage;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
